<include file="Public:header" />
<form  method="post" class="definewidth m20" id="user-form">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">登录名</td>
        <td><input type="text" name="name"/></td>
    </tr>
    <tr>
        <td class="tableleft">密码</td>
        <td><input type="password" name="password"/></td>
    </tr>
    <tr>
        <td class="tableleft">确认密码</td>
        <td><input type="password" name="repassword"/></td>
    </tr>
    <tr>
        <td class="tableleft">真实姓名</td>
        <td><input type="text" name="nickname"/></td>
    </tr>

    <tr>
        <td class="tableleft">性别</td>
        <td>
            <input type="radio" name="gender" value="1" checked/> 男
            <input type="radio" name="gender" value="2"/> 女
        </td>
    </tr>
    <tr>
        <td class="tableleft">出生年月</td>
        <td>
            <input type="date" name="borth"/>
        </td>
    </tr>
    <tr>
        <td class="tableleft">角色</td>
        <td>
            <select name="role_id">
                <foreach name="role_list" item="r_val">
                    <option value="{$r_val['role_id']}">{$r_val.name}</option>
                </foreach>
            </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">入职时间</td>
        <td>
            <input type="date" name="work_time" value="{$now}"/>
        </td>
    </tr>
    <tr>
        <td class="tableleft">状态</td>
        <td>
            <input type="radio" name="status" value="1" checked/> 启用
            <input type="radio" name="status" value="2"/> 禁用
        </td>
    </tr>
    <tr>
        <td class="tableleft"></td>
        <td>
            <button type="button" class="btn btn-primary" type="button" id="add-user">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
        </td>
    </tr>
</table>
</form>

<script>
    $(function () {
        $('#backid').click(function(){
            window.location.href="{:U('User/Index')}";
        });
        $("#add-user").click(function () {
            data = $("#user-form").serialize();
            $.post(
                    "{:U('User/save')}",
                    data,
                    function(xhr){
                        if(200 == xhr.status){
                            alert(xhr.msg);
                            location.href = "{:U('User/Index')}"
                        }else {
                            alert(xhr.msg);
                        }
                    }
            );
        });
    });
</script>

<include file="Public:footer" />